<template>
  <div class="dialog_container" v-show="visible">
    <!-- 遮罩层 -->
    <div class="zhe" @click="changeVis"></div>
    <div class="div" :style="{width:width}">
      <!-- 头 -->
      <div class="title">
        <slot name="diaHeader"></slot>
        <span @click="fn">x</span>
      </div>
      <!-- 内容 -->
      <div class="main">
        <slot name="diaMain"></slot>
      </div>
      <!-- 底部 -->
      <div class="footer">
        <slot name="foot" > </slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props:{
    visible:{
      type:Boolean,
      default:true
    },
    width:{
      type:String,
      default:'50%'
    },
  },
  data() {
    return {
      // visible: false
    }
  },
  methods: {
    changeVis() {
      this.$emit("closeMask")
    },
    fn(){
      this.$emit("closeDialog",!this.visible)
    }
  },
};
</script>

<style scoped>
.dialog_container .zhe {
  position: fixed;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0);
  opacity: 0.6;
  /* //css3动画属性 */
  animation: mask1 1s linear forwards;
  top: 0;
  left: 0;
}
.div {
  width: 50%;
  
  background-color: #fff;
  border-radius: 8px;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
  position: fixed;
  animation: dialog1 .5s linear forwards;
  padding-left: 20px;
  padding-right: 20px;
}
.div  .title{
  width: 100%;
  height: 35px;
  line-height: 35px;
  display: flex;
  justify-content: space-between;
  padding-right: 23px;
  padding-bottom: 10px;
}
.div .footer {
  width: 100%;
  padding-left: 75%;
  padding-bottom: 15px;
}
/* //定义下透明度动画 */
@keyframes mask1 {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.5;
  }
}
@keyframes dialog1 {
  from {
    top: 0;
  }
  to {
    top: 50%;
  }
}
</style>